// 封装请求方法
function request(url, method = "GET", data = {}, header = {}) {
  // Promise 构造函数创建的对象，可以直接 then 运行回调函数使用
  return new Promise((resolve, reject) => {
    wx.request({
      url,
      method,
      data,
      header,
      success: res => {
        resolve(res)
      },
      fail: res => {
        reject(res)
      }
    })
  })
}

request.baseURL = "https://autumnfish.cn/wx/api/public/v1"

request.get = (url, data) => {
  return request( request.baseURL + url, "GET", data )
}

request.post = (url, data) => {
  return request( request.baseURL + url, "POST", data )
}
// 暴露函数
export default request
